﻿using System;
using System.Collections.Generic;
using System.Text;

using Gx.Dal.Employee;//数据
using Gx.Model.Entity;//实体
using Gx.Common;

namespace Gx.Bll.Employee
{
    public class G_StockInGoodsInfoBll
    {


        public bool AddG_StockInGoodsInfo(G_StockInGoodsInfo model)
        {
            using (G_StockInGoodsInfoDal dal = new G_StockInGoodsInfoDal())
            {
                return dal.AddG_StockInGoodsInfo(model);
            }
        }


        private List<G_StockInGoodsInfo> GetG_StockInGoodsInfoList(string strWhere)
        {
            using (G_StockInGoodsInfoDal dal = new G_StockInGoodsInfoDal())
            {
                return dal.GetG_StockInGoodsInfoList(strWhere);
            }
        }

        public List<G_StockInGoodsInfo> GetG_StockInGoodsInfoList(
        int pageIndex, int pageSize, out int totalCount)
        {
            using (G_StockInGoodsInfoDal dal = new G_StockInGoodsInfoDal())
            {
                int PageIndex = (pageIndex - 1) * pageSize + 1;
                int PageSize = pageIndex * pageSize;
                StringBuilder strWhere = new StringBuilder();
                return dal.GetG_StockInGoodsInfoList(strWhere.ToString(), PageIndex, PageSize, out totalCount);
            }
        }

        private int GetG_StockInGoodsInfoCount(string strWhere)
        {
            using (G_StockInGoodsInfoDal dal = new G_StockInGoodsInfoDal())
            {
                return dal.GetG_StockInGoodsInfoCount(strWhere);
            }
        }

        public G_StockInGoodsInfo GetG_StockInGoodsInfoModel(int stockInGoodsId)
        {
            using (G_StockInGoodsInfoDal dal = new G_StockInGoodsInfoDal())
            {
                return dal.GetG_StockInGoodsInfoModel(stockInGoodsId);
            }
        }

        public List<G_StockInGoodsInfo> GetG_StockInGoodsInfoList(int PurchaseOrderId)
        {
            using (G_StockInGoodsInfoDal dal = new G_StockInGoodsInfoDal())
            {
                List<G_StockInGoodsInfo> list = dal.GetG_StockInGoodsInfoList(PurchaseOrderId);
                list.ForEach(x => x.StrAddTime = x.AddTime.ToStringyyyyMMdd());
                return list;
            }
        }

        public List<G_StockInGoodsInfo> GetG_StockInGoodsInfoDetails(int StockInId)
        {
            using (G_StockInGoodsInfoDal dal = new G_StockInGoodsInfoDal())
            {
                StringBuilder strWhere = new StringBuilder();
                strWhere.AppendFormat(" AND StockInId={0}", StockInId);
                List<G_StockInGoodsInfo> list = dal.GetG_StockInGoodsInfoList(strWhere.ToString());
                list.ForEach(x =>
                {
                    x.StrGoodsNum = x.GoodsNum.ToStringf2();
                });
                return list;
            }
        }


    }
}
